#pragma once

#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

class FileGuard {
private:
    int &_fd;

public:
    FileGuard(int &fd);

    ~FileGuard(void);
};

FileGuard::FileGuard(int &fd)
    : _fd(fd)
{
}

FileGuard::~FileGuard(void)
{
    if (_fd) {
        close(_fd);
    }
}